

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>Network Encoding &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/_sphinx_javascript_frameworks_compat.js"></script>
        <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/doctools.js"></script>
        <script src="../../_static/sphinx_highlight.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex/" />
    <link rel="search" title="Search" href="../../search/" />
    <link rel="next" title="网络协议" href="../network-protocol/" />
    <link rel="prev" title="msgr2 协议（ msgr2.0 和 msgr2.1 ）" href="../msgr2/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../internals/">Ceph 内幕</a></li>
      <li class="breadcrumb-item active">Network Encoding</li>
      <li class="wy-breadcrumbs-aside">
            <a href="../../_sources/dev/network-encoding.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../" class="icon icon-home"> Ceph
          

          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../start/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephfs/">Ceph 文件系统</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../monitoring/">监控概览</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../developer_guide/">开发者指南</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../internals/">Ceph 内幕</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../balancer-design/">Ceph 如何均衡（读写、容量）</a></li>
<li class="toctree-l2"><a class="reference internal" href="../blkin/">Tracing Ceph With LTTng</a></li>
<li class="toctree-l2"><a class="reference internal" href="../blkin/#tracing-ceph-with-blkin">Tracing Ceph With Blkin</a></li>
<li class="toctree-l2"><a class="reference internal" href="../bluestore/">BlueStore Internals</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ceph_krb_auth/">如何配置好 Ceph Kerberos 认证的详细文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cephfs-mirroring/">CephFS Mirroring</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cephfs-reclaim/">CephFS Reclaim Interface</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cephfs-snapshots/">CephFS 快照</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cephx/">Cephx</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cephx_protocol/">Cephx 认证协议详细阐述</a></li>
<li class="toctree-l2"><a class="reference internal" href="../config/">配置管理系统</a></li>
<li class="toctree-l2"><a class="reference internal" href="../config-key/">config-key layout</a></li>
<li class="toctree-l2"><a class="reference internal" href="../context/">CephContext</a></li>
<li class="toctree-l2"><a class="reference internal" href="../continuous-integration/">Continuous Integration Architecture</a></li>
<li class="toctree-l2"><a class="reference internal" href="../corpus/">资料库结构</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cpu-profiler/">Oprofile 的安装</a></li>
<li class="toctree-l2"><a class="reference internal" href="../crush-msr/">CRUSH MSR (Multi-step Retry)</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cxx/">C++17 and libstdc++ ABI</a></li>
<li class="toctree-l2"><a class="reference internal" href="../deduplication/">去重</a></li>
<li class="toctree-l2"><a class="reference internal" href="../delayed-delete/">CephFS delayed deletion</a></li>
<li class="toctree-l2"><a class="reference internal" href="../dev_cluster_deployment/">开发集群的部署</a></li>
<li class="toctree-l2"><a class="reference internal" href="../dev_cluster_deployment/#id5">在同一机器上部署多套开发集群</a></li>
<li class="toctree-l2"><a class="reference internal" href="../development-workflow/">开发流程</a></li>
<li class="toctree-l2"><a class="reference internal" href="../documenting/">为 Ceph 写作文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../dpdk/">Ceph messenger DPDKStack</a></li>
<li class="toctree-l2"><a class="reference internal" href="../encoding/">序列化（编码、解码）</a></li>
<li class="toctree-l2"><a class="reference internal" href="../erasure-coded-pool/">纠删码存储池</a></li>
<li class="toctree-l2"><a class="reference internal" href="../file-striping/">File striping</a></li>
<li class="toctree-l2"><a class="reference internal" href="../freebsd/">FreeBSD Implementation details</a></li>
<li class="toctree-l2"><a class="reference internal" href="../generatedocs/">Ceph 文档的构建</a></li>
<li class="toctree-l2"><a class="reference internal" href="../health-reports/">Health Reports</a></li>
<li class="toctree-l2"><a class="reference internal" href="../iana/">IANA 号</a></li>
<li class="toctree-l2"><a class="reference internal" href="../kclient/">Testing changes to the Linux Kernel CephFS driver</a></li>
<li class="toctree-l2"><a class="reference internal" href="../kclient/#step-one-build-the-kernel">Step One: build the kernel</a></li>
<li class="toctree-l2"><a class="reference internal" href="../kclient/#step-two-create-a-vm">Step Two: create a VM</a></li>
<li class="toctree-l2"><a class="reference internal" href="../kclient/#step-three-networking-the-vm">Step Three: Networking the VM</a></li>
<li class="toctree-l2"><a class="reference internal" href="../kubernetes/">Hacking on Ceph in Kubernetes with Rook</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libcephfs_proxy/">Design of the libcephfs proxy</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libs/">库体系结构</a></li>
<li class="toctree-l2"><a class="reference internal" href="../logging/">集群日志的用法</a></li>
<li class="toctree-l2"><a class="reference internal" href="../logs/">调试日志</a></li>
<li class="toctree-l2"><a class="reference internal" href="../macos/">在 MacOS 上构建</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mempool_accounting/">What is a mempool?</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mempool_accounting/#some-common-mempools-that-we-can-track">Some common mempools that we can track</a></li>
<li class="toctree-l2"><a class="reference internal" href="../messenger/">Messenger notes</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mon-bootstrap/">Monitor bootstrap</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mon-elections/">Monitor Elections</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mon-on-disk-formats/">ON-DISK FORMAT</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mon-osdmap-prune/">FULL OSDMAP VERSION PRUNING</a></li>
<li class="toctree-l2"><a class="reference internal" href="../msgr2/">msgr2 协议（ msgr2.0 和 msgr2.1 ）</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Network Encoding</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#conventions">Conventions</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#integers">Integers</a></li>
<li class="toctree-l4"><a class="reference internal" href="#complex-types">Complex Types</a></li>
<li class="toctree-l4"><a class="reference internal" href="#variable-arrays">Variable Arrays</a></li>
<li class="toctree-l4"><a class="reference internal" href="#primitive-aliases">Primitive Aliases</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#structures">Structures</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#optional">Optional</a></li>
<li class="toctree-l4"><a class="reference internal" href="#pair">Pair</a></li>
<li class="toctree-l4"><a class="reference internal" href="#triple">Triple</a></li>
<li class="toctree-l4"><a class="reference internal" href="#list">List</a></li>
<li class="toctree-l4"><a class="reference internal" href="#blob">Blob</a></li>
<li class="toctree-l4"><a class="reference internal" href="#map">Map</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#id1">Complex Types</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#utime-t">utime_t</a></li>
<li class="toctree-l4"><a class="reference internal" href="#ceph-entity-name">ceph_entity_name</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../network-protocol/">网络协议</a></li>
<li class="toctree-l2"><a class="reference internal" href="../object-store/">对象存储架构概述</a></li>
<li class="toctree-l2"><a class="reference internal" href="../osd-class-path/">OSD class path issues</a></li>
<li class="toctree-l2"><a class="reference internal" href="../peering/">互联</a></li>
<li class="toctree-l2"><a class="reference internal" href="../perf/">Using perf</a></li>
<li class="toctree-l2"><a class="reference internal" href="../perf_counters/">性能计数器</a></li>
<li class="toctree-l2"><a class="reference internal" href="../perf_histograms/">Perf histograms</a></li>
<li class="toctree-l2"><a class="reference internal" href="../placement-group/">PG （归置组）说明</a></li>
<li class="toctree-l2"><a class="reference internal" href="../quick_guide/">开发者指南（快速）</a></li>
<li class="toctree-l2"><a class="reference internal" href="../rados-client-protocol/">RADOS 客户端协议</a></li>
<li class="toctree-l2"><a class="reference internal" href="../rbd-diff/">RBD 增量备份</a></li>
<li class="toctree-l2"><a class="reference internal" href="../rbd-export/">RBD Export &amp; Import</a></li>
<li class="toctree-l2"><a class="reference internal" href="../rbd-layering/">RBD Layering</a></li>
<li class="toctree-l2"><a class="reference internal" href="../release-checklists/">Release checklists</a></li>
<li class="toctree-l2"><a class="reference internal" href="../release-process/">Ceph Release Process</a></li>
<li class="toctree-l2"><a class="reference internal" href="../seastore/">SeaStore</a></li>
<li class="toctree-l2"><a class="reference internal" href="../sepia/">Sepia 社区测试实验室</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session_authentication/">Session Authentication for the Cephx Protocol</a></li>
<li class="toctree-l2"><a class="reference internal" href="../testing/">测试笔记</a></li>
<li class="toctree-l2"><a class="reference internal" href="../versions/">Public OSD Version</a></li>
<li class="toctree-l2"><a class="reference internal" href="../vstart-ganesha/">NFS CephFS-RGW Developer Guide</a></li>
<li class="toctree-l2"><a class="reference internal" href="../wireshark/">Wireshark Dissector</a></li>
<li class="toctree-l2"><a class="reference internal" href="../zoned-storage/">Zoned Storage Support</a></li>
<li class="toctree-l2"><a class="reference internal" href="../osd_internals/">OSD 开发者文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mds_internals/">MDS 开发者文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../radosgw/">RADOS 网关开发者文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ceph-volume/">ceph-volume 开发者文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../crimson/">Crimson developer documentation</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../hardware-monitoring/">硬件监控</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <section id="network-encoding">
<h1>Network Encoding<a class="headerlink" href="#network-encoding" title="Permalink to this heading"></a></h1>
<p>This describes the encoding used to serialize data.  It doesn’t cover specific
objects/messages but focuses on the base types.</p>
<p>The types are not self documenting in any way.  They can not be decoded unless
you know what they are.</p>
<section id="conventions">
<h2>Conventions<a class="headerlink" href="#conventions" title="Permalink to this heading"></a></h2>
<section id="integers">
<h3>Integers<a class="headerlink" href="#integers" title="Permalink to this heading"></a></h3>
<p>The integer types used will be named <code class="docutils literal notranslate"><span class="pre">{signed}{size}{endian}</span></code>.  For example
<code class="docutils literal notranslate"><span class="pre">u16le</span></code> is an unsigned 16 bit integer encoded in little endian byte order
while <code class="docutils literal notranslate"><span class="pre">s64be</span></code> is a signed 64 bit integer in big endian.  Additionally <code class="docutils literal notranslate"><span class="pre">u8</span></code>
and <code class="docutils literal notranslate"><span class="pre">s8</span></code> will represent signed and unsigned bytes respectively.  Signed
integers use two’s complement encoding.</p>
</section>
<section id="complex-types">
<h3>Complex Types<a class="headerlink" href="#complex-types" title="Permalink to this heading"></a></h3>
<p>This document will use a c-like syntax for describing structures.  The
structure represents the data that will go over the wire.  There will be no
padding between the elements and the elements will be sent in the order they
appear.  For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">struct</span> <span class="n">foo</span> <span class="p">{</span>
        <span class="n">u8</span>    <span class="n">tag</span><span class="p">;</span>
        <span class="n">u32le</span> <span class="n">data</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
<p>When encoding the values <code class="docutils literal notranslate"><span class="pre">0x05</span></code> and <code class="docutils literal notranslate"><span class="pre">0x12345678</span></code> respectively will appear on
the wire as <code class="docutils literal notranslate"><span class="pre">05</span> <span class="pre">78</span> <span class="pre">56</span> <span class="pre">34</span> <span class="pre">12</span></code>.</p>
</section>
<section id="variable-arrays">
<h3>Variable Arrays<a class="headerlink" href="#variable-arrays" title="Permalink to this heading"></a></h3>
<p>Unlike c, length arrays can be used anywhere in structures and will be inline in
the protocol.  Furthermore the length may be described using an earlier item in
the structure.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">struct</span> <span class="n">blob</span> <span class="p">{</span>
        <span class="n">u32le</span> <span class="n">size</span><span class="p">;</span>
        <span class="n">u8</span>    <span class="n">data</span><span class="p">[</span><span class="n">size</span><span class="p">];</span>
        <span class="n">u32le</span> <span class="n">checksum</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
<p>This structure is encoded as a 32 bit size, followed by <code class="docutils literal notranslate"><span class="pre">size</span></code> data bytes,
then a 32 bit checksum.</p>
</section>
<section id="primitive-aliases">
<h3>Primitive Aliases<a class="headerlink" href="#primitive-aliases" title="Permalink to this heading"></a></h3>
<p>These types are just aliases for primitive types.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">//</span> <span class="n">From</span> <span class="o">/</span><span class="n">src</span><span class="o">/</span><span class="n">include</span><span class="o">/</span><span class="n">types</span><span class="o">.</span><span class="n">h</span>

<span class="n">typedef</span> <span class="n">u32le</span> <span class="n">epoch_t</span><span class="p">;</span>
<span class="n">typedef</span> <span class="n">u32le</span> <span class="n">ceph_seq_t</span><span class="p">;</span>
<span class="n">typedef</span> <span class="n">u64le</span> <span class="n">ceph_tid_t</span><span class="p">;</span>
<span class="n">typedef</span> <span class="n">u64le</span> <span class="n">version_t</span><span class="p">;</span>
</pre></div>
</div>
</section>
</section>
<section id="structures">
<h2>Structures<a class="headerlink" href="#structures" title="Permalink to this heading"></a></h2>
<p>These are the way structures are encoded.  Note that these structures don’t
actually exist in the source but are the way that different types are encoded.</p>
<section id="optional">
<h3>Optional<a class="headerlink" href="#optional" title="Permalink to this heading"></a></h3>
<p>Optionals are represented as a presence byte, followed by the item if it exists.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>struct ceph_optional&lt;T&gt; {
        u8 present;
        T  element[present? 1 : 0]; // Only if present is non-zero.
}
</pre></div>
</div>
<p>Optionals are used to encode <code class="docutils literal notranslate"><span class="pre">boost::optional</span></code>.</p>
</section>
<section id="pair">
<h3>Pair<a class="headerlink" href="#pair" title="Permalink to this heading"></a></h3>
<p>Pairs are simply the first item followed by the second.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">struct</span> <span class="n">ceph_pair</span><span class="o">&lt;</span><span class="n">A</span><span class="p">,</span><span class="n">B</span><span class="o">&gt;</span> <span class="p">{</span>
        <span class="n">A</span> <span class="n">a</span><span class="p">;</span>
        <span class="n">B</span> <span class="n">b</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
<p>Pairs are used to encode <code class="docutils literal notranslate"><span class="pre">std::pair</span></code>.</p>
</section>
<section id="triple">
<h3>Triple<a class="headerlink" href="#triple" title="Permalink to this heading"></a></h3>
<p>Triples are simply the tree elements one after another.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">struct</span> <span class="n">ceph_triple</span><span class="o">&lt;</span><span class="n">A</span><span class="p">,</span><span class="n">B</span><span class="p">,</span><span class="n">C</span><span class="o">&gt;</span> <span class="p">{</span>
        <span class="n">A</span> <span class="n">a</span><span class="p">;</span>
        <span class="n">B</span> <span class="n">b</span><span class="p">;</span>
        <span class="n">C</span> <span class="n">c</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
<p>Triples are used to encode <code class="docutils literal notranslate"><span class="pre">ceph::triple</span></code>.</p>
</section>
<section id="list">
<h3>List<a class="headerlink" href="#list" title="Permalink to this heading"></a></h3>
<p>Lists are represented as an element count followed by that many elements.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">struct</span> <span class="n">ceph_list</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span> <span class="p">{</span>
        <span class="n">u32le</span> <span class="n">length</span><span class="p">;</span>
        <span class="n">T</span>     <span class="n">elements</span><span class="p">[</span><span class="n">length</span><span class="p">];</span>
<span class="p">}</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The size of the elements in the list are not necessarily uniform.</p>
</div>
<p>Lists are used to encode <code class="docutils literal notranslate"><span class="pre">std::list</span></code>, <code class="docutils literal notranslate"><span class="pre">std::vector</span></code>, <code class="docutils literal notranslate"><span class="pre">std::deque</span></code>,
<code class="docutils literal notranslate"><span class="pre">std::set</span></code> and <code class="docutils literal notranslate"><span class="pre">ceph::unordered_set</span></code>.</p>
</section>
<section id="blob">
<h3>Blob<a class="headerlink" href="#blob" title="Permalink to this heading"></a></h3>
<p>A Blob is simply a list of bytes.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">struct</span> <span class="n">ceph_string</span> <span class="p">{</span>
        <span class="n">ceph_list</span><span class="o">&lt;</span><span class="n">u8</span><span class="o">&gt;</span><span class="p">;</span>
<span class="p">}</span>

<span class="o">//</span> <span class="n">AKA</span>

<span class="n">struct</span> <span class="n">ceph_string</span> <span class="p">{</span>
        <span class="n">u32le</span> <span class="n">size</span><span class="p">;</span>
        <span class="n">u8</span>    <span class="n">data</span><span class="p">[</span><span class="n">size</span><span class="p">];</span>
<span class="p">}</span>
</pre></div>
</div>
<p>Blobs are used to encode <code class="docutils literal notranslate"><span class="pre">std::string</span></code>, <code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*</span></code> and <code class="docutils literal notranslate"><span class="pre">bufferlist</span></code>.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The content of a Blob is arbratrary binary data.</p>
</div>
</section>
<section id="map">
<h3>Map<a class="headerlink" href="#map" title="Permalink to this heading"></a></h3>
<p>Maps are a list of pairs.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">struct</span> <span class="n">ceph_map</span><span class="o">&lt;</span><span class="n">K</span><span class="p">,</span><span class="n">V</span><span class="o">&gt;</span> <span class="p">{</span>
        <span class="n">ceph_list</span><span class="o">&lt;</span><span class="n">ceph_pair</span><span class="o">&lt;</span><span class="n">K</span><span class="p">,</span><span class="n">V</span><span class="o">&gt;&gt;</span><span class="p">;</span>
<span class="p">}</span>

<span class="o">//</span> <span class="n">AKA</span>

<span class="n">struct</span> <span class="n">ceph_map</span><span class="o">&lt;</span><span class="n">K</span><span class="p">,</span><span class="n">V</span><span class="o">&gt;</span> <span class="p">{</span>
        <span class="n">u32le</span> <span class="n">length</span><span class="p">;</span>
        <span class="n">ceph_pair</span><span class="o">&lt;</span><span class="n">K</span><span class="p">,</span><span class="n">V</span><span class="o">&gt;</span> <span class="n">entries</span><span class="p">[</span><span class="n">length</span><span class="p">];</span>
<span class="p">}</span>
</pre></div>
</div>
<p>Maps are used to encode <code class="docutils literal notranslate"><span class="pre">std::map</span></code>, <code class="docutils literal notranslate"><span class="pre">std::multimap</span></code> and
<code class="docutils literal notranslate"><span class="pre">ceph::unordered_map</span></code>.</p>
</section>
</section>
<section id="id1">
<h2>Complex Types<a class="headerlink" href="#id1" title="Permalink to this heading"></a></h2>
<p>These aren’t hard to find in the source but the common ones are listed here for
convenience.</p>
<section id="utime-t">
<h3>utime_t<a class="headerlink" href="#utime-t" title="Permalink to this heading"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">//</span> <span class="n">From</span> <span class="o">/</span><span class="n">src</span><span class="o">/</span><span class="n">include</span><span class="o">/</span><span class="n">utime</span><span class="o">.</span><span class="n">h</span>
<span class="n">struct</span> <span class="n">utime_t</span> <span class="p">{</span>
        <span class="n">u32le</span> <span class="n">tv_sec</span><span class="p">;</span>  <span class="o">//</span> <span class="n">Seconds</span> <span class="n">since</span> <span class="n">epoch</span><span class="o">.</span>
        <span class="n">u32le</span> <span class="n">tv_nsec</span><span class="p">;</span> <span class="o">//</span> <span class="n">Nanoseconds</span> <span class="n">since</span> <span class="n">the</span> <span class="n">last</span> <span class="n">second</span><span class="o">.</span>
<span class="p">}</span>
</pre></div>
</div>
</section>
<section id="ceph-entity-name">
<h3>ceph_entity_name<a class="headerlink" href="#ceph-entity-name" title="Permalink to this heading"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">//</span> <span class="n">From</span> <span class="o">/</span><span class="n">src</span><span class="o">/</span><span class="n">include</span><span class="o">/</span><span class="n">msgr</span><span class="o">.</span><span class="n">h</span>
<span class="n">struct</span> <span class="n">ceph_entity_name</span> <span class="p">{</span>
        <span class="n">u8</span>    <span class="nb">type</span><span class="p">;</span> <span class="o">//</span> <span class="n">CEPH_ENTITY_TYPE_</span><span class="o">*</span>
        <span class="n">u64le</span> <span class="n">num</span><span class="p">;</span>
<span class="p">}</span>

<span class="o">//</span> <span class="n">CEPH_ENTITY_TYPE_</span><span class="o">*</span> <span class="n">defined</span> <span class="ow">in</span> <span class="o">/</span><span class="n">src</span><span class="o">/</span><span class="n">include</span><span class="o">/</span><span class="n">msgr</span><span class="o">.</span><span class="n">h</span>
</pre></div>
</div>
</section>
</section>
</section>



<div id="support-the-ceph-foundation" class="admonition note">
  <p class="first admonition-title">Brought to you by the Ceph Foundation</p>
  <p class="last">The Ceph Documentation is a community resource funded and hosted by the non-profit <a href="https://ceph.io/en/foundation/">Ceph Foundation</a>. If you would like to support this and our other efforts, please consider <a href="https://ceph.io/en/foundation/join/">joining now</a>.</p>
</div>


           </div>
           
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="../msgr2/" class="btn btn-neutral float-left" title="msgr2 协议（ msgr2.0 和 msgr2.1 ）" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="../network-protocol/" class="btn btn-neutral float-right" title="网络协议" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).</p>
  </div>

   

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>